﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ViewClient.aspx.cs" Inherits="ViewClient" MaintainScrollPositionOnPostback="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <asp:Panel ID="AuthenticatedHeaderPanel" runat="server">
        <ul id="user">
            <li>
                <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Login.aspx" />
            </li>
        </ul>

        <div id="header-inner">
            <div class="textt">
            <h4>
                <asp:Label runat="server" ID="WelcomeBackMessage"></asp:Label>
                <asp:label id="lblMessage" runat="server" enableviewstate="false" />
            </h4>
            </div>
        </div>
    </asp:Panel>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Menu" Runat="Server">
<div id="left">
<div id = "navigation">
    <asp:Panel runat="server" ID="AuthenticatedMenuPanel" Width="200px">
        <div id="menu-header">
            <div class="menutext">
                <asp:Label ID="Label3" runat="server" Text="Menu"/>
            </div> 
        </div>
          <asp:Menu ID="Menu1" runat="server" StaticDisplayLevels="3" BackColor="White" DynamicHoverStyle-BorderStyle="NotSet" Width="200px">
              <Items>
                
                <asp:MenuItem Text="Home" Value="Home" navigateurl="Default.aspx">
                  <asp:MenuItem Text="New Document" Value="New Document" navigateurl="AddDocument.aspx">                   
                   </asp:MenuItem>
                </asp:MenuItem>

                <asp:MenuItem Text="Users" Value="My_Users" navigateurl="MyUsers.aspx">
                  <asp:MenuItem Text="New User" Value="New_User" navigateurl="AddUser.aspx">
                   </asp:MenuItem>
                </asp:MenuItem>
               
                <asp:MenuItem Text="Companies" Value="Companies" navigateurl="MyCompanies.aspx">
                  <asp:MenuItem Text="New Company" Value="New_Company" navigateurl="AddCompany.aspx">
                   </asp:MenuItem>
                </asp:MenuItem>
                
                <asp:MenuItem Text="Clients" Value="Clients" navigateurl="MyClients.aspx">
                  <asp:MenuItem Text="New Client" Value="New_Client" navigateurl="AddClient.aspx">
                   </asp:MenuItem>
                </asp:MenuItem>

              </Items>
          </asp:Menu>
     </asp:Panel>
    </div>
</div>
</asp:Content>

<asp:Content ID="Content3" runat="server" contentplaceholderid="MainContent">
   <div id= "right"> 
    <asp:Panel runat="server" ID="AuthenticatedMessagePanel">
        <div class="box">
            <div class ="title">
                <h6>
                    <asp:Label ID="Label4" runat="server" Text="Client:"></asp:Label>
                </h6>
            </div>
        <div class="lists">
            <table id="tab">
                <tbody>
                    <tr>
                        <th>Name:</th>
                        <td>
                            <asp:Label ID="lblName" runat="server" Text=" "></asp:Label>
                            <asp:Label ID="lbl_company_id" runat="server" Text=" " Visible="false"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <th>Registration number:</th>
                        <td>
                            <asp:Label ID="lblRegnr" runat="server" Text=" "></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <th>Vat:</th>
                        <td>
                            <asp:Label ID="lblVat" runat="server" Text=" "></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <th>Main company:</th>
                        <td>
                            <asp:Label ID="lblMain" runat="server" Text=" "></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <th>Position:</th>
                        <td>
                            <asp:Label ID="lblPosition" runat="server" Text=" "></asp:Label>
                        </td>
                    </tr>
                </tbody>
            </table>
                <div class="button">
                <ul>
                    <li>
                        <asp:LinkButton ID="bt_delete_company" runat="server" Text="Delete"></asp:LinkButton>
                    </li>
                </ul>
                </div>
            </div>
        </div>
        <div class="box box-left">
            <div class ="title">
                <h6>
                    <asp:Label ID="Label1" runat="server" Text="Client banks:"></asp:Label>
                </h6>
            </div>
        <div class="lists">
            <asp:ListView ID="Bank_list" runat="server" 
                onitemcommand="Bank_list_ItemCommand" onitemdatabound="Bank_list_ItemDataBound" 
                onitemediting="Bank_list_ItemEditing" onsorting="Bank_list_Sorting">
                <LayoutTemplate>
                    <table ID="gradient-style">
                        <thead>
                            <tr>
                                <th>Bank</th>
                                <th>Swift</th>
                                <th>Account</th>
                                <th colspan="5">Options</th>
                            </tr>
                        </thead>
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                        <tfoot>
                            <tr>
                                <th colspan="9" style="text-align:right">
                                </th>
                            </tr>
                        </tfoot>
                    </table>
                </LayoutTemplate>
                <AlternatingItemTemplate>
                    <tr>
                        <td ID="company_bankID" runat="server">
                            <asp:Label ID="id_company_bankLabel" runat="server" Text='<%# Eval("_id_company_bank") %>' />
                        </td>
                        <td ID="bankID" runat="server">
                            <asp:Label ID="id_bankLabel" runat="server" Text='<%# Eval("_id_bank") %>' />
                        </td>
                        <td ID="companyID" runat="server">
                            <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' />
                        </td>
                        <td ID="accountID" runat="server">
                            <asp:Label ID="id_accountLabel" runat="server" Text='<%# Eval("_id_account_number") %>' />
                        </td>
                        <td>
                            <asp:Label ID="bank_nameLabel" runat="server" Text='<%# Eval("_bank_name") %>' />
                        </td>
                        <td>
                            <asp:Label ID="bank_swiftLabel" runat="server" Text='<%# Eval("_bank_swift") %>' />
                        </td>
                        <td>
                            <asp:Label ID="bank_accountLabel" runat="server" Text='<%# Eval("_account") %>' />
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                        </td>
                    </tr>
                </AlternatingItemTemplate>
                <ItemTemplate>
                    <tr>
                        <td ID="company_bankID" runat="server">
                            <asp:Label ID="id_company_bankLabel" runat="server" Text='<%# Eval("_id_company_bank") %>' />
                        </td>
                        <td ID="bankID" runat="server">
                            <asp:Label ID="id_bankLabel" runat="server" Text='<%# Eval("_id_bank") %>' />
                        </td>
                        <td ID="companyID" runat="server">
                            <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' />
                        </td>
                        <td ID="accountID" runat="server">
                            <asp:Label ID="id_accountLabel" runat="server" Text='<%# Eval("_id_account_number") %>' />
                        </td>
                        <td>
                            <asp:Label ID="bank_nameLabel" runat="server" Text='<%# Eval("_bank_name") %>' />
                        </td>
                        <td>
                            <asp:Label ID="bank_swiftLabel" runat="server" Text='<%# Eval("_bank_swift") %>' />
                        </td>
                        <td>
                            <asp:Label ID="bank_accountLabel" runat="server" Text='<%# Eval("_account") %>' />
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
                <%--            <EditItemTemplate>
                <td  id="company_bankID" runat="server">
                    <asp:Label ID="id_company_bankLabel" runat="server" Text='<%# Eval("_id_company_bank") %>' />
                </td>
                <td  id="bankID" runat="server">
                    <asp:Label ID="id_bankLabel" runat="server" Text='<%# Eval("_id_bank") %>' />
                </td>
                <td  id="companyID" runat="server">
                    <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' />
                </td>
                <td colspan="2">
                    <asp:DropDownList ID="Drop_bank" DataSourceID="SqlDataSource1" DataTextField="bank_name" DataValueField="ID" runat="server" AutoPostBack="true" />
                    <asp:TextBox ID="tb_bank_name_insert" runat="server" ValidationGroup="add" Text='<% Eval("_bank_name") %>' >Bank</asp:TextBox>
                <asp:RequiredFieldValidator ID="bank_name_insertValidator" runat="server" ControlToValidate="tb_bank_name_insert" ErrorMessage="<div>Bank name cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add"></asp:RequiredFieldValidator>
                </td>
                <td>
                    <asp:TextBox ID="tb_bank_swift_insert" runat="server" ValidationGroup="add" Text='<%Eval("_bank_swift") %>' >Swift</asp:TextBox>
                    <asp:RequiredFieldValidator ID="bank_swift_insertValidator" runat="server" ControlToValidate="tb_bank_name_insert" ErrorMessage="<div>Bank swift cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add"></asp:RequiredFieldValidator>
                </td>
                <td>                    
                    <asp:LinkButton ID="lnkUpdate" runat="server" CommandName="Update_bank" ValidationGroup="edit">Update</asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="lnkCancel" runat="server" CommandName="Cancel_bank">Cancel</asp:LinkButton>                    
                </td>
            </EditItemTemplate>--%>
                <%--            <InsertItemTemplate>
            <tr runat="server">
                <td colspan="2">
                    <asp:DropDownList ID="Drop_bank" DataSourceID="SqlDataSource1" DataTextField="bank_name" DataValueField="ID" runat="server" AutoPostBack="true" />
                    <asp:TextBox ID="tb_bank_name_insert" runat="server" ValidationGroup="add" Text='<% Eval("_bank_name") %>' >Bank</asp:TextBox>
                <asp:RequiredFieldValidator ID="bank_name_insertValidator" runat="server" ControlToValidate="tb_bank_name_insert" ErrorMessage="<div>Bank name cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add"></asp:RequiredFieldValidator>
                </td>
                <td>
                    <asp:TextBox ID="tb_bank_swift_insert" runat="server" ValidationGroup="add" Text='<%Eval("_bank_swift") %>' >Swift</asp:TextBox>
                    <asp:RequiredFieldValidator ID="bank_swift_insertValidator" runat="server" ControlToValidate="tb_bank_name_insert" ErrorMessage="<div>Bank swift cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add"></asp:RequiredFieldValidator>
                </td>
                <td colspan="2" style="text-align:center;">
                   <asp:LinkButton ID="lnkInsert" runat="server" CommandName="Insert_bank" ValidationGroup="add">Insert</asp:LinkButton>                    
                </td>
            </tr>
            </InsertItemTemplate>--%>
            </asp:ListView>
            <fieldset id="fieldset">
                <legend class="text">Add new client bank & account:</legend>
                    <table id="tab">
                        <tbody>
                             <tr>
                                <th class="buttons">Bank:</th>
                                <td class="buttons">
                                    <asp:DropDownList ID="Drop_bank" runat="server" />
                                    <asp:RequiredFieldValidator ID="Drop_client_bank_Validator" runat="server" ControlToValidate="Drop_bank" ErrorMessage="<div>Select clients bank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_bank" InitialValue="--Select--"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                             <tr>
                                <th class="buttons">Account nr.:</th>
                                <td class="buttons">
                                    <asp:TextBox ID="tb_account" runat="server" Width="184px" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tb_account" ErrorMessage="<div>Account number cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add_bank"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                        </tbody>
                     </table>
                     <div class="button">
                        <ul>
                            <li>
                                <asp:LinkButton ID="bt_ok_bank" runat="server" onclick="bt_ok_bank_Click" Text="Add" Width="60px" ValidationGroup="add_bank"/>
                            </li>
                        </ul>
                    </div>
                    <asp:Label ID="lbl_edit" runat="server" Text="false" Visible="False" />
                    &nbsp;<asp:Label ID="lbl_company_bankID" runat="server" Text="Label" Visible="False" />
                    &nbsp;<asp:Label ID="lbl_companyID" runat="server" Text="Label" Visible="False" />
                    &nbsp;<asp:Label ID="lbl_accountID" runat="server" Text="Label" Visible="False" />
            </fieldset>
        </div>
        </div>
        <div class="box box-right">
            <div class ="title">
                <h6>
                    <asp:Label ID="Label2" runat="server" Text="Client addresses:"></asp:Label>
                </h6>
            </div>
        <div class="lists">
            <asp:ListView ID="Address_list" runat="server" onitemcommand="Address_list_ItemCommand" 
                onitemdatabound="Address_list_ItemDataBound" onitemediting="Address_list_ItemEditing" onsorting="Address_list_Sorting">
                <LayoutTemplate>
                    <table ID="gradient-style">
                        <thead>
                            <tr>
                                <th >Address</th>
                                <th colspan="2">Options</th>
                            </tr>
                        </thead>
                        <tr ID="itemPlaceholder" runat="server">
                        </tr>
                        <tfoot>
                            <tr>
                                <th colspan="4" style="text-align:right">
                                </th>
                            </tr>
                        </tfoot>
                    </table>
                </LayoutTemplate>
                <AlternatingItemTemplate>
                    <tr>
                        <td ID="addressID" runat="server">
                            <asp:Label ID="id_addressLabel" runat="server" Text='<%# Eval("_id_address") %>' />
                        </td>
                        <td ID="companyID" runat="server">
                            <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' />
                        </td>
                        <td>
                            <asp:Label ID="addressLabel" runat="server" Text='<%# Eval("_address") %>' />
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                        </td>
                    </tr>
                </AlternatingItemTemplate>
                <ItemTemplate>
                    <tr>
                        <td ID="addressID" runat="server">
                            <asp:Label ID="id_addressLabel" runat="server" Text='<%# Eval("_id_address") %>' />
                        </td>
                        <td ID="companyID" runat="server">
                            <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' />
                        </td>
                        <td>
                            <asp:Label ID="addressLabel" runat="server" Text='<%# Eval("_address") %>' />
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
                        </td>
                        <td>
                            <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
                <%--<EditItemTemplate>
                    <td ID="addressID" runat="server">
                        <asp:Label ID="id_addressLabel" runat="server" Text='<%# Eval("_id_address") %>' />
                    </td>
                    <td ID="companyID" runat="server">
                        <asp:Label ID="id_companyLabel" runat="server" Text='<%# Eval("_id_company") %>' />
                    </td>
                    <td>
                        <asp:TextBox ID="tb_address" runat="server" Text='<% #Bind("_address")%>' TextMode="MultiLine" ValidationGroup="edit"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="addressValidator" runat="server" ControlToValidate="tb_address" Display="Dynamic" ErrorMessage="<div>Address cannot be blank!</div>" SetFocusOnError="true" ValidationGroup="edit"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkUpdate" runat="server" CommandName="Update_address" ValidationGroup="edit">Update</asp:LinkButton>
                    </td>
                    <td>
                        <asp:LinkButton ID="lnkCancel" runat="server" CommandName="Cancel_address">Cancel</asp:LinkButton>
                    </td>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <tr ID="Tr1" runat="server">
                        <td>
                            <asp:TextBox ID="tb_address_insert" runat="server" Text='<%Eval("_address") %>' TextMode="MultiLine" ValidationGroup="add">Add new address!</asp:TextBox>
                            <asp:RequiredFieldValidator ID="addressValidator" runat="server" ControlToValidate="tb_address_insert" Display="Dynamic" ErrorMessage="<div>Address cannot be blank!</div>" SetFocusOnError="true" ValidationGroup="add"></asp:RequiredFieldValidator>
                        </td>
                        <td colspan="2" style="text-align:center;">
                            <asp:LinkButton ID="lnkInsert" runat="server" CommandName="Insert_address" ValidationGroup="add">Insert</asp:LinkButton>
                        </td>
                    </tr>
                </InsertItemTemplate>--%>
            </asp:ListView>
            <fieldset id="fieldset">
                <legend>Add new client address</legend>
                    <table id="tab">
                        <tbody>
                             <tr>
                                <th class="buttons">Address:</th>
                                <td class="buttons">
                                    <asp:TextBox ID="tb_address" TextMode="MultiLine" runat="server" Width="210px" />
                                    <asp:RequiredFieldValidator ID="PositionValidator" runat="server" ControlToValidate="tb_address" ErrorMessage="<div>Address cannot be blank.</div>" SetFocusOnError="true" Display="Dynamic" ValidationGroup="add"/>
                                </td>
                            </tr>
                        </tbody>
                     </table>
                     <div class="button">
                        <ul>
                            <li>
                                <asp:LinkButton ID="bt_ok_address" runat="server" Text="Add" Width="60px" onclick="bt_ok_address_Click" ValidationGroup="add"/>
                            </li>
                        </ul>
                    </div>
                    <asp:Label ID="lbl_edit_address" runat="server" Text="false" Visible="False" />
                    <asp:Label ID="lbl_address_id" runat="server" Visible="False"/>
            </fieldset>
        </div>
      </div>
    </asp:Panel>
</div>
</asp:Content>
